<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>07class和style绑定</title>
    <style>
        .myred{
            color:red;
        }
        .myblock{
            font-weight:bold;
        }
    </style>
</head>
<body>
<div id="app">
    计算器：{{ counter }}<br>
    <!--css绑定-->
    <p v-bind:class="redClassName">CSS样式绑定01</p>
    <p v-bind:class="{ 'myred': true, 'myblock': true }">CSS样式绑定02</p>
    <p v-bind:class="getClassName()">CSS样式绑定03</p>
    <p v-bind:class="compClassName">CSS样式绑定04</p>
    <p v-bind:class="[redClassName,blockClassName]">CSS样式绑定05</p>
    <!--style绑定-->
    <p v-bind:style="{color:'red'}">style样式绑定01</p>
    <p v-bind:style="{color:redStyleName}">style样式绑定02</p>
    <p v-bind:style="redStyleObject">style样式绑定03</p>
    <p v-bind:style="[redStyleObject,blockStyleObject]">style样式绑定04</p>
</div>
<script src="../vue.global.3.0.5.js"></script>
<script>
    //声明一个选项对象
    const App={
        //初始数据
        data() {
            return {
                counter: 100,
                redClassName: 'myred',
                blockClassName: 'myblock',
                isMyred: true,
                isMyblock: true,
                redStyleName: 'red',
                redStyleObject: { 'color':'red' },
                blockStyleObject: {'font-weight': 'bold'}
            }
        },
        methods: {
            getClassName() {
                return { 'myred': this.isMyred, 'myblock': this.isMyblock };
            }
        },
        computed: {
            compClassName: {
                get() {
                    return { 'myred': this.isMyred, 'myblock': this.isMyblock };
                },
                set(value) {

                }
            }
        }
    }

    //全局API对象，创建应用对象返回(选项对象).挂载方法(DOM节点)
    const vm = Vue.createApp(App).mount("#app");
</script>
</body>
</html>